*This file creates productivity  table A.6


*Define controls
global sharecontrols c.lnlabor_all1943#year  c.power_labor_share1943#year c.ln_relative_wage1943#year c.ln_establishments1943#year c.skilled1943#year c.ln_inputs_all1943#year c.ln_valueadded1943#year 

*Input data
use "$path/industry_data.dta", clear

*Import industry skill data. See paper for details.
preserve
use "$path/ind_edu.dta", clear
tempfile education
gen low_edu=(high_edu!=1)
save `education' 
restore

joinby digt2 using `education' , unmatched (master) 

preserve
keep if year==1943

replace high_edu=0 if high_edu==.&repa_sharel==0
replace low_edu=0 if low_edu==.&repa_sharel==0

gen h_std=(repa_sharel*high_edu)
egen h_std2=std(repa_sharel*high_edu)

gen l_std=(repa_sharel*low_edu)
egen l_std2=std(repa_sharel*low_edu)

gen hs_linear=ln_repa_tot*high_edu
gen ls_linear=ln_repa_tot*low_edu

keep isic h_std h_std2 l_std l_std2 low_edu high_edu hs_linear ls_linear  
tempfile education2
save `education2' 
restore

drop _merge

joinby isic using `education2' , unmatched (master) 

gen high_skill_post=h_std2*post
gen low_skill_post=l_std2*post

label var high_skill_post "HS x Reparations share x Post"
label var low_skill_post "LS x Reparations share x Post"

*Redefine productivity as value added per person instead of production per person	
drop ln_productivity
gen ln_productivity=ln((gross_value_real-Inputs_all_real)/(Labor_all))

*Estimations
foreach var in ln_productivity {

reghdfe `var' scaledpost , absorb(year isic $sharecontrols) vce(cluster isic) 
estadd local ii "162"
estimates store `var's1 
estadd local established "None"
estadd local ife "\checkmark"
estadd local yfe "\checkmark"

reghdfe `var'  scaledpost  if timberpaper==0  , absorb(year isic $sharecontrols) vce(cluster isic) 
estadd local ii "142"
estimates store `var's2
estadd local established "Established"
estadd local ife "\checkmark"
estadd local yfe "\checkmark"

reghdfe `var'   high_skill_post low_skill_post, absorb(year isic $sharecontrols) vce(cluster isic) 
estadd local ii "162"
estimates store `var'hl3 
estadd local established "None"
estadd local ife "\checkmark"
estadd local yfe "\checkmark"
}

esttab  ln_productivitys1  ln_productivitys2 ln_productivityhl3    using "$tables/productivity_table.tex", replace booktabs  mlabels(none) ///
	mgroups("ln Labor Productivity"  , pattern(1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
	compress lines star(* .1 ** .05 *** .01) label ///
	b(%9.3f) se(%9.3f) stats(N ii ife yfe established  , labels( "\textit{N}" "Industries" "Industry FE" "Year FE" "Omitted")  ///
	fmt(0 2)) keep(scaledpost high_skill_post low_skill_post )  nodepvars nomtitle nonotes
	